package com.guaigen.campus.member.config;

import com.guaigen.campus.common.interceptor.LogInterceptor;
import com.guaigen.campus.common.interceptor.MemberInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    @Resource
    MemberInterceptor memberInterceptor;

    @Resource
    LogInterceptor logInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(memberInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/com/guaigen/campus/member/hello",
                        "/com/guaigen/campus/member/member/send-code",
                        "/com/guaigen/campus/member/member/login"
                );

        registry.addInterceptor(logInterceptor);
    }
}
